<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace web\api\controller;

/**
 * Description of Member
 * 用户
 * @author shilinqing
 */
class Syspara extends UserBase {

    /*
     * 图片上传
     * api/SysPara/image_upload
     */
    public function image_upload()
    {
        $baseStr = $this->_post('base_str');
        $waterMark = $this->_post('water_mark');
        if (empty($baseStr)) return $this->failJSON(lang('SYS_IMG_REQUIRE'));
        $type = $this->_post('type');
        $userId = $this->user_id;
        switch ($type){
            case 1 : //1实名认证
                $savePath = 'auth/'.$userId.'/';
                break;
            case 3: //微信
                $savePath = 'wechat/'.$userId.'/';
                break;
            case 4: //支付宝
                $savePath = 'alipay/'.$userId.'/';
                break;
            case 5: //头像
                $savePath = 'head/'.$userId.'/';
                break;
            case 6: //分享
                $savePath = 'share/'.$userId.'/';
                break;
            case 7: //银行卡
                $savePath = 'bank/'.$userId.'/';
                break;
            case 8: //USDT 二维码
                $savePath = 'usdt/'.$userId.'/';
                break;
            case 9: //USDT 二维码
                $savePath = 'feedback/'.$userId.'/';
                break;
            case 10: //约pa
                $savePath = 'about/'.$userId.'/';
                break;
            default:
                $savePath = 'default/';
                break;
        }
        $res = $this->base_img_upload($baseStr,$userId,$savePath,$waterMark);
        if ($res['success'] == true){
            return $this->successJSON($res['path']);
        }else{
            return $this->failJSON($res['message']);
        }

    }
    /*
     * 获取区域列表
     * URI：api/Address/areaList
     */
    public function areaList()
    {
        $pid = $this->_post('pid');
        if(empty($pid)) $pid = 0 ;
        $areaM = new \addons\about\model\Area();
        $list = $areaM->where(['pid'=>$pid,'level'=>0])->select();
        return $this->successJSON($list);
    }


    /**
     * 系统协议
     */
    public function agreement(){
        $type = $this->_post('type');
        if(!in_array($type, [1,2,3,4,5])){
            return $this->failJSON(lang('LOGIN_ERROR_TYPE'));
        }
        $m = (new \web\common\model\sys\SysOemModel())->where(['type' => $type])->find();
        $m['agreement'] = htmlspecialchars_decode($m['agreement']);
        return $this->successJSON($m['agreement']);

    }

}

